package cn.edu.jxau.test;

import org.junit.Test;

public class UnionFindTest {

    @Test
    public void test() {

        int n = 20;
        UnionFind unionFind = new UnionFind(n);
        int connCounter = 0; // connection counter 记录连接数
        while (connCounter < (n - 1)) {
            int p = (int) (Math.random() * n);
            int q = (int) (Math.random() * n);
            System.out.println(p+"  "+q);
            if (!unionFind.connected(p, q)) {
                unionFind.union(p,q);
                connCounter++;
            }
        }
        System.out.println("connCounter:"+connCounter);
        System.out.println(unionFind);
    }
}
